/*
 * Copyright (C) 2000-2005 Philips Electronics N.V.
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or 
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; see the file gnu_license.txt.  If not, write to
 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  
 * 
 */
#include "macros.h"
#include "cfront_y.h"

extern int cfront_scan (void);

static Int tag_num = 0;

Ident New_Tag (void)
{
  char s[1024];
  sprintf (s, "TAG_%d", tag_num++);
  return Make_identifier (s);
}

expression make_comma_expr (SrcInfo l, expression hd, List_expression tl)
{
  expression e;
  
  if (tl == NULL) return Create_comma_expression (l, NULL, hd);
  e = make_comma_expr (l, List_expression_data(tl), List_expression_next(tl));
  comma_expression_pre(e) = Create_List_expression (hd, comma_expression_pre(e));
  return e;
}

int  cfront_lex (void)
{ int token = cfront_scan ();
  Ident id;
  if (token != Identsym) return token; 
  id = cfront_lval.Identsym_type;
  if (is_type_def(id)) {
    cfront_lval.Type_identsym_type = cfront_lval.Identsym_type;
    return Type_identsym;
  }
  return token;
}

declaration parameter_id (SrcInfo l, declaration_specifiers s, Ident id)
{
  declarator d = Create_Par_Id_Decl(l, id);
  return Create_declaration(l, SS(l), s, Create_List_declarator(d, NULL));
}
